package cn.kgc.ssm.web.controller;

import cn.kgc.ssm.web.annotations.Logs;
import cn.kgc.ssm.web.enums.Operations;
import cn.kgc.ssm.web.response.ResponseResult;
import cn.kgc.ssm.web.service.MessageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpSession;

/**
 * @author 课工场
 * @date 2024/7/31
 * @description   留言模块
 */
@RestController
@RequestMapping("message")
public class MessageController {

    @Autowired
    private MessageService messageService;

    // 分页
    @GetMapping("page")
    public ResponseResult messagePage(Integer page,Integer limit,String memberName){
      return   messageService.messagePage(page,limit,memberName);
    }

    // 编辑留言状态
    @Logs(operation = Operations.UPDATE,model = "留言模块")
    @PostMapping("edit")
    public ResponseResult editMessage(Integer id){
        return   messageService.editMessage(id);
    }

    // 删除留言
    @Logs(operation = Operations.DELETE,model = "留言模块")
    @PostMapping("delete")
    public ResponseResult deleteMessage(Integer[] ids){
        return   messageService.deleteMessage(ids);
    }


    @PostMapping("publish")
    public ResponseResult publishMessage(String content, HttpSession session){

       return messageService.publishMessage(content,session);
    }


}
